<?php

namespace AppBundle\Libs;

use AppBundle\Entity\P2pBidding;
use AppBundle\Entity\P2pInstallmentBorrowers;
use Doctrine\Common\Persistence\ObjectManager;


/**
 * Created by PhpStorm.
 * User: kcswag
 * Date: 12/3/17
 * Time: 3:00 PM
 */

class Storage
{
    private $entityManager;

    public function __construct(ObjectManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function storeProjectData($data=[]){
        $project = new P2pBidding();

        $project->setBStatus('edit');
        $this->entityManager->persist($project);
        $this->entityManager->flush();

        return $project;
    }

    public function storeBorrowerData($data=[]){

        $borrower = new P2pInstallmentBorrowers();

        $borrower->setName($data['name']);
        $borrower->setCellphone($data['cellphone']);
        $borrower->setAddress($data['address']);
        $borrower->setIncome($data['income']);

        $this->entityManager->persist($borrower);
        $this->entityManager->flush();

        return $borrower;
    }

}